package com.srwl.mytx.widget;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.srwl.mytx.R;


/**
 * 营私政策对话框
 */
public class PrivacyPolicyDialog extends AlertDialog {

    private Context context;
    private ConfirmListener confirmListener;


    public PrivacyPolicyDialog(Context context) {
        super(context);
        this.context = context;
    }


    protected PrivacyPolicyDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        this.context = context;
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.authority_agreement);


        Button btnAgree = findViewById(R.id.btn_agree);
        btnAgree.setOnClickListener(v -> {
            dismiss();

            if (confirmListener != null) {
                confirmListener.onConfirmListener();
            }
        });
        TextView tvContent = findViewById(R.id.tv_content);
        String[] stringArray = context.getResources().getStringArray(R.array.authority_agreement);
        StringBuilder agreement = new StringBuilder();
        agreement.append("    ");
        for (String s : stringArray) {
            agreement.append(s).append("\n    ");
        }
        tvContent.setText(agreement.toString());
    }


    public void setConfirmListener(ConfirmListener confirmListener) {
        this.confirmListener = confirmListener;
    }

    public interface ConfirmListener {
        void onConfirmListener();
    }

}
